package com.rules.admin.unit.expect;

import com.gillion.grule.client.core.Context;
import com.gillion.grule.client.logger.LoggerAppenderHolder;

public class ActionExpect extends Expect {
   private String expectRuleName;

   public ExpectMatcherResult expect(Context context) {
      ExpectMatcherResult expectMatcherResult = ExpectMatcherResult.ofActionExpect();
      LoggerAppenderHolder.log("开始匹配动作：{}", new Object[]{this.expectRuleName});
      if (ActionsHolder.hasAction(this.expectRuleName)) {
         expectMatcherResult.setMatch(true);
      } else {
         expectMatcherResult.setMatch(false);
         expectMatcherResult.setMessage("未执行到规则" + this.expectRuleName);
      }

      return expectMatcherResult;
   }

   public String getExpectRuleName() {
      return this.expectRuleName;
   }

   public void setExpectRuleName(String expectRuleName) {
      this.expectRuleName = expectRuleName;
   }

   public String toString() {
      return "ActionExpect(expectRuleName=" + this.getExpectRuleName() + ")";
   }

   public boolean equals(Object o) {
      if (o == this) {
         return true;
      } else if (!(o instanceof ActionExpect)) {
         return false;
      } else {
         ActionExpect other = (ActionExpect)o;
         if (!other.canEqual(this)) {
            return false;
         } else {
            Object this$expectRuleName = this.getExpectRuleName();
            Object other$expectRuleName = other.getExpectRuleName();
            if (this$expectRuleName == null) {
               if (other$expectRuleName != null) {
                  return false;
               }
            } else if (!this$expectRuleName.equals(other$expectRuleName)) {
               return false;
            }

            return true;
         }
      }
   }

   protected boolean canEqual(Object other) {
      return other instanceof ActionExpect;
   }

   public int hashCode() {

      int result = 1;
      Object $expectRuleName = this.getExpectRuleName();
      result = result * 59 + ($expectRuleName == null ? 43 : $expectRuleName.hashCode());
      return result;
   }
}
